<?php

declare(strict_types=1);

namespace app\api\controller;

use app\api\validate\User;
use app\BaseController;
use app\common\lib\Show;
use think\facade\Cache;

class Home extends BaseController
{
//最近小区
    public function getHouseDetail(){
        $longitude = $this->request->param("longitude", "", "trim");
        $latitude = $this->request->param("latitude", "", "trim");

        $map = [
            ['pid','=',0]
        ];
        $houseBis = new \app\common\business\House();
        $list = $houseBis->getListByWhereWithOrder($map,0,0,'sort desc,id desc','id,name,longitude,latitude');

        $result = [];
        if (!empty($list)) {
            //根据经纬度计算距离
            $data = [
                'longitude'=>$longitude,
                'latitude'=>$latitude
            ];
            $list = $houseBis->handlerListByOrder($list,$data);//根据order返回不同list
            $result = $list[0];
        }

        return Show::success($result);
    }
}
